package com.zyyx.box.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zyyx.common.annotation.Log;
import com.zyyx.common.core.controller.BaseController;
import com.zyyx.common.core.domain.AjaxResult;
import com.zyyx.common.enums.BusinessType;
import com.zyyx.box.domain.Box;
import com.zyyx.box.service.IBoxService;
import com.zyyx.common.utils.poi.ExcelUtil;
import com.zyyx.common.core.page.TableDataInfo;

/**
 * 盒子设备管理Controller
 * 
 * @author xw
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/box/box")
public class BoxController extends BaseController
{
    @Autowired
    private IBoxService boxService;

    /**
     * 查询盒子设备管理列表
     */
    @PreAuthorize("@ss.hasPermi('box:box:list')")
    @GetMapping("/list")
    public TableDataInfo list(Box box)
    {
        startPage();
        List<Box> list = boxService.selectBoxList(box);
        return getDataTable(list);
    }


    /**
     * 导出盒子设备管理列表
     */
    @PreAuthorize("@ss.hasPermi('box:box:export')")
    @Log(title = "盒子设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Box box)
    {
        List<Box> list = boxService.selectBoxList(box);
        ExcelUtil<Box> util = new ExcelUtil<Box>(Box.class);
        util.exportExcel(response, list, "盒子设备管理数据");
    }

    /**
     * 获取盒子设备管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('box:box:query')")
    @GetMapping(value = "/{boxId}")
    public AjaxResult getInfo(@PathVariable("boxId") Long boxId)
    {
        return success(boxService.selectBoxByBoxId(boxId));
    }

    /**
     * 新增盒子设备管理
     */
    @PreAuthorize("@ss.hasPermi('box:box:add')")
    @Log(title = "盒子设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Box box)
    {
        return toAjax(boxService.insertBox(box));
    }

    /**
     * 修改盒子设备管理
     */
    @PreAuthorize("@ss.hasPermi('box:box:edit')")
    @Log(title = "盒子设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Box box)
    {
        return toAjax(boxService.updateBox(box));
    }

    /**
     * 删除盒子设备管理
     */
    @PreAuthorize("@ss.hasPermi('box:box:remove')")
    @Log(title = "盒子设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{boxIds}")
    public AjaxResult remove(@PathVariable Long[] boxIds)
    {
        return toAjax(boxService.deleteBoxByBoxIds(boxIds));
    }
}
